// 引入request
import request from "@/utils/request";

import type { AttrListModel, AttrModel } from "./model/attrModel";
import type { CategoryIdsModel } from "./model/categoryModel";

// 定义枚举类型的api接口地址
enum API {
  GetAttrList = "/admin/product/attrInfoList",
  DeleteAttrById = "/admin/product/deleteAttr",
  AddOrUpdateAttr = "/admin/product/saveAttrInfo",
}

//根据三个分类id获取平台属性对象数组的数据
export const reqGetAttrList = ({ category1Id, category2Id, category3Id }: CategoryIdsModel) => request.get<any, AttrListModel>(API.GetAttrList + `/${category1Id}/${category2Id}/${category3Id}`);

//根据平台属性的id删除平台属性对象数据
export const reqDeleteAttrById = (attrId: number) => request.delete<any, null>(API.DeleteAttrById + `/${attrId}`);

//添加或者修改平台属性对象，参数是平台属性对象
export const reqAddOrUpdateAttr = (Attr: AttrModel) => request.post<any, null>(API.AddOrUpdateAttr, Attr);
